package com.warrantyhotel.android.widget;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.warrantyhotel.android.R;

public class BalloonView extends FrameLayout {

	public BalloonView(Context context, int count) {
		super(context);
		int left = 30;
		int bottom = 40;

		DisplayMetrics metrics = new DisplayMetrics();
		((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);

		switch (metrics.densityDpi) {
		case DisplayMetrics.DENSITY_MEDIUM:
			left = 30;
			bottom = 40;
			break;
		case DisplayMetrics.DENSITY_HIGH:
			left = 40;
			bottom = 50;
			break;
		}

		setPadding(left, 0, 0, bottom);
		LinearLayout layout = new LinearLayout(context);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.balloon, layout);
		TextView balloonCount = (TextView) view.findViewById(R.id.balloon_counter);
		balloonCount.setText(String.valueOf(count));

		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.gravity = Gravity.NO_GRAVITY;

		addView(layout, params);

	}

}
